package pers.burgess.xml.util;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileUtil {
	
	/**
	 * Wirte string to file with byte stream
	 * 
	 * @param s 
	 * @param file
	 * @throws IOException
	 */
	public static void writeToFile(String s, File file) throws IOException {
		
		ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
		FileOutputStream os = new FileOutputStream(file);
		int len = -1;
		byte[] buff = new byte[2048];
		while ((len = is.read(buff)) != -1) {
			os.write(buff, 0, len);
		}
		
		is.close();
		os.close();
		
	}

}
